package com.leyou.page.web;

import com.leyou.page.service.PageService;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

import java.io.File;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

@Controller
public class PageController {

    @Autowired
    private PageService pageService;


    @GetMapping("item/{id}.html")
    public String toItemPage(@PathVariable("id") Long id, Model model) {

        //查询数据
        Map<String, Object> attributes = pageService.loadModel(id);
        model.addAllAttributes(attributes);
        pageService.createHtml(id);
        return "item";
    }


}
